package com.xiaoshuaila.settings.service;

import com.xiaoshuaila.settings.dao.Dictypedao;
import com.xiaoshuaila.settings.dao.Dicvaluedao;
import com.xiaoshuaila.settings.domain.Dictype;
import com.xiaoshuaila.settings.domain.Dicvalue;
import com.xiaoshuaila.tool.SqlSessionUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DicserviceImpl implements Dicservice {
    Dictypedao dictypedao=
            SqlSessionUtil.getSqlSession().getMapper(Dictypedao.class);
    Dicvaluedao dicvaluedao=
            SqlSessionUtil.getSqlSession().getMapper(Dicvaluedao.class);

    @Override
    public Map<String, List<Dicvalue>> getall() {
        Map<String, List<Dicvalue>>map=new HashMap<>();
        List<Dictype>list=new ArrayList<>();
        list=dictypedao.select();
        for (Dictype dic:list
             ) {
            map.put(dic.getCode(),dicvaluedao.select(dic.getCode()));
        }
        return map;
    }
}
